package com.dgut.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dgut.app.service.TypeService;
import com.dgut.common.entity.Category;
import com.dgut.common.entity.Item;
import com.dgut.common.mapper.CategoryMapper;
import com.dgut.common.mapper.ItemMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author zyq
 * @Date 2022/4/14 23:13
 * @Description TODO
 * @Version 1.0
 **/
@Service
@Slf4j
@RequiredArgsConstructor
public class TypeServiceImpl implements TypeService {
    private final CategoryMapper categoryMapper;
    private final ItemMapper itemMapper;

    @Override
    public List<Item> listItemByCategory(Integer category) {
        QueryWrapper<Item> wrapper = new QueryWrapper<>();
        wrapper.eq("category_id", category);
        return itemMapper.selectList(wrapper);
    }

    @Override
    public List<Category> listAllCategory() {
        return categoryMapper.selectList(null);
    }
}
